/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.web.servlet;

import com.web.entity.Administrator;
import com.web.service.AdministratorService;
import com.web.serviceimpl.AdministratorServiceImpl;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.Servlet;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 *
 * @author lenovo
 */
@WebServlet("/mapw")
public class ModifyAdministratorPwdServlet extends HttpServlet {

    AdministratorService administratorService = new AdministratorServiceImpl();
    
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        
        
        req.setCharacterEncoding("utf-8");
        String Aid = req.getParameter("Aid");
        String Apwd = req.getParameter("Apwd");
        
        //收到修改后的密码，封装成一个administrator对象
        Administrator administrator = new Administrator(Aid,Apwd);
    
        int rows = administratorService.modifyAdministratorApwd(administrator);
        
        //生成响应内容，判断密码是否修改成功
        resp.getWriter().print(rows);
        PrintWriter out=resp.getWriter();
        System.out.println(rows);
    }

}
